<?php session_start();?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <LINK REL=StyleSheet HREF="maintenancePagesCSS.css" TYPE="text/css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
<?php
    include "ProductDetails.php";
    include "ProductDetailsDao.php";
    include "Datasource.php";

    $tempPart = new ProductDetails();
    $productDetailsDao = new ProductDetailsDao();
    $conn = new Datasource("localhost","theanykey","root","");

    $tempPart = $productDetailsDao->getObject($conn, $_GET["id"]);

?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>

        <center>
<form name="ProductDetailsForm" action="PartEditFunc.php" method="post" id="ProductDetailsForm">

                <table width="1000" border="0" bgcolor="#454343">
                  <tr>
                    <th scope="col"><center>
                      <p><img src="images/TitleProductInformation.gif" alt="Product Information" width="514" height="67"></p>
                      <table border="0" class="EditTable">
                        
                        <tbody>
                          <tr>
                            <th>Product ID:</th>
                            <td><b><?php print($tempPart->getProductID());  ?></b>
                                <input type="hidden" name="PK" id="PK" value="<?php print($tempPart->getProductID());  ?>" />                            </td>
                          </tr>
                          <tr>
                            <th>*Manufacturer:</th>
                            <td><input type="text" name="Manufacturer" value="<?php print($tempPart->getManufacturer());  ?>"  size="25" id="Manufacturer"
                            </td>
                          </tr>
                          <tr>
                            <th>*Model Number:</th>
                            <td><input type="text" name="ModelNo" value="<?php print($tempPart->getModelNo());  ?>" size="25" id="ModelNo" /></td>
                          </tr>
                          <tr>
                            <th>Serial Number:</th>
                            <td><input type="text" name="SerialNo" value="<?php print($tempPart->getSerialNo());  ?>" size="25" id="SerialNo"/></td>
                          </tr>
                          <tr>
                            <th>*Company Price:</th>
                            <td><input type="text" name="CompanyPrice" id="CompanyPrice" value="<?php print($tempPart->getCompanyPrice());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <th>*Customer Price:</th>
                            <td><input type="text" name="CustomerPrice" id="CustomerPrice" value="<?php print($tempPart->getCustomerPrice());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <th>Tech Notes:</th>
                            <td><textarea name="TechNotes" cols ="50" rows ="4"><?php print($tempPart->gettechNotes());  ?></textarea></td>
                          </tr>
                          <tr>
                            <td colspan=2><center>
                                <input type="button" name="Update" value="Update" onClick="submitEditProduct();"/>
                                <input type="button" name="btnReload" value="Reload Values" onClick="javascript:location.reload(true);"/>
                            </center></td>
                          </tr>
                        </tbody>
                      </table>
                      <address>
                        * denotes required field
                      </address>
                    </center>
                      <center>
                        <br>
         <script src="links.js" language="javascript" type="text/javascript"></script>
                <script type="text/javascript">
            writeProductLinks("", "");
                </script>
                      </center>                    </th>
                  </tr>
                  <tr>
                    <th height="104" scope="col">&nbsp;</th>
                  </tr>
                </table>
      <p>&nbsp;</p>
                </form>
            </center>
        </body>

    <script type="text/javascript">
        function submitEditProduct()
        {
            var strCorrect = "Please correct the following errors:\n";
            var strCompare = strCorrect;
            strCorrect += checkFields();
            if(strCorrect == strCompare)
            {
               document.getElementById("ProductDetailsForm").submit();
            }
            else
            {
                alert(strCorrect);
            }
        }

        function checkFields()
        {
            var str = "";

            str += (isNaN(parseFloat(document.getElementById("CustomerPrice").value))) ? "  - Customer Price should be a number\n"
                    : "";

            str += (isNaN(parseFloat(document.getElementById("CompanyPrice").value))) ? "  - Company Price should be a number\n"
                    : "";

            str += (document.getElementById("Manufacturer").value == "") ? "  - Manufacturer is Blank\n" : "";

            str += (document.getElementById("ModelNo").value == "") ? "  - Model Number is Blank\n" : "";

            str += (document.getElementById("CompanyPrice").value == "") ? "  - Company Price is Blank\n" : "";

            str += (document.getElementById("CustomerPrice").value == "") ? "  - Customer Price is Blank\n" : "";

            return str;
        }
    </script>
</html>

